# Copyright (C) 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//tools/build:rules.bzl", "go_stripped_binary")

go_library(
    name = "go_default_library",
    srcs = ["main.go"],
    importpath = "github.com/google/gapid/cmd/gapis",
    visibility = ["//visibility:private"],
    deps = [
        "//core/app:go_default_library",
        "//core/app/auth:go_default_library",
        "//core/app/crash:go_default_library",
        "//core/event/task:go_default_library",
        "//core/log:go_default_library",
        "//core/os/android/adb:go_default_library",
        "//core/os/device/bind:go_default_library",
        "//core/os/device/remotessh:go_default_library",
        "//core/os/file:go_default_library",
        "//core/os/fuchsia/ffx:go_default_library",
        "//core/text:go_default_library",
        "//gapir/client:go_default_library",
        "//gapis/database:go_default_library",
        "//gapis/replay:go_default_library",
        "//gapis/server:go_default_library",
        "//gapis/service:go_default_library",
        "//gapis/service/path:go_default_library",
        "//gapis/stringtable:go_default_library",
        "//gapis/trace:go_default_library",
        "@org_golang_google_grpc//grpclog:go_default_library",
    ],
)

go_stripped_binary(
    name = "gapis",
    data = [
        "//cmd/gapir/cc:gapir",
        "//core/vulkan/vk_virtual_swapchain/cc:json",
        "//core/vulkan/vk_virtual_swapchain/cc:libVkLayer_VirtualSwapchain",
        "//gapii/cc:libgapii",
        "//gapii/vulkan/vk_graphics_spy/cc:json",
    ] + select({
        "@gapid//tools/build:linux": [
            "//core/vulkan/vk_api_timing_layer/cc:json",
            "//core/vulkan/vk_api_timing_layer/cc:libVkLayer_CPUTiming",
            "//core/vulkan/vk_memory_tracker_layer/cc:json",
            "//core/vulkan/vk_memory_tracker_layer/cc:libVkLayer_MemoryTracker",
        ],
        "//conditions:default": [],
    }) + select({
        "//tools/build:no-android": [],
        "//conditions:default": [
            "//gapidapk/android/apk:arm64-v8a.apk",
            "//gapidapk/android/apk:armeabi-v7a.apk",
            "//gapidapk/android/apk:x86.apk",
        ],
    }),
    embed = [":go_default_library"],
    visibility = ["//visibility:public"],
)
